Skip to content

Add on_record to support tracing::field::Empty and span.record#89

Merged
oli-obk merged 2 commits into
davidbarsky:mainfrom
seyyed-dev:main
Sep 23, 2025
Merged

Add on_record to support tracing::field::Empty and span.record#89
oli-obk merged 2 commits into
davidbarsky:mainfrom
seyyed-dev:main

Conversation

@seyyed-dev

Copy link
Copy Markdown
Contributor

Currently, when tracing::field::Empty is used with span.record() calls, the recorded values are lost and not displayed in span traces. This PR introduces on_record functionality to preserve and display recorded values.

let lazy = span!(Level::DEBUG, "lazy span", work_units = Empty);
lazy.record("work_units", &3);
lazy.in_scope(|| {
    info!("doing some work");
});
drop(lazy);

Before

1:main└─┐open: deferred::lazy span 
1:main  ├─ INFO deferred doing some work
1:main ┌┘close(v): deferred::lazy span 

After

1:main└─┐open: deferred::lazy span work_units=3
1:main  ├─ INFO deferred doing some work
1:main ┌┘close(v): deferred::lazy span work_units=3

@seyyed-dev

seyyed-dev commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

If you review commit by commit, you can see the effect of on_record

@seyyed-dev

Copy link
Copy Markdown
Contributor Author

Clippy errors of the main branch are fixed at #90

@seyyed-dev
seyyed-dev force-pushed the main branch 3 times, most recently from 21df80c to 04a547c Compare September 21, 2025 17:02
@oli-obk

oli-obk commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator

Good catch, thank you! and thanks for the CI fixes in separate PRs

@oli-obk
oli-obk merged commit 0f4d5bd into davidbarsky:main Sep 23, 2025
4 checks passed
@oli-obk

oli-obk commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator

published as 0.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants